import { Public } from "../../financial"
import './index.less'
import ZingTable from "@/pages/login/ZingTable"
import { Switch } from "antd"
import { useEffect, useState } from "react"
import { useNavigate } from 'react-router-dom'
import {getTemplate} from '@/services/settings/voucherTemplate'
const headValue=[
    {name:'名称',key:'name'},
    {name:'状态',key:'state'},
    {name:'操作',key:'operate'}
]
const VoucherTemplate=()=>{
    let [bodyValue,setbodyValue]=useState(
        {})
    useEffect(()=>{
        getTemplate(sessionStorage.getItem('userId')).then((res)=>{
            console.log(res);
            let _data=res.data.map((v)=>{
                return({
                    name:v.modelName,
                    state:<Switch defaultChecked />,
                    operate:['修改','删除']
                })
            })
            setbodyValue({id:sessionStorage.getItem('userId'),content:_data})
        })

    },[])
    const navigate = useNavigate();
    const toEdit=()=>{
        navigate('/home/proof/copyProof')
    } 
    return(
        <div style={{height:700}}>
            <Public header={"凭证模板"}></Public>
            <div className="VTadd"><button className="VTaddBut">增加</button></div>
            <div style={{paddingLeft:50}}><ZingTable Tstyle={{width:1200,hbackgroundColor:'#22AB82',dlineHeight:5}}  theads={headValue} tbodys={bodyValue} operation1={toEdit}>
                </ZingTable></div>
        </div>
    )
}
export default VoucherTemplate